<template>
	<view class="detail">
		<view class="title">
			{{detail.title}}
		</view>
		<view class="time">
			<text>{{formatDate(detail.create_time*1000)}}</text>
		</view>
		<view class="brief" v-if="detail.brief">
			{{detail.brief}}
		</view>
		<view class="content">
			<rich-text :nodes="detail.content"></rich-text>
		</view>
	</view>
</template>

<script>
	import {formatDate} from "@/utils/util.js"
	import {getNoticeDetail} from "@/api/public.js";
	export default{
		name:"notice-detail",
		data(){
			return{
				detail:{}
			}
		},
		onLoad(option) {
			this.getDetail(option.id);
		},
		methods:{
			formatDate(value){
				return formatDate(value)
			},
			async getDetail(id){
				let res = await getNoticeDetail({id:id});
				if(res.code === 1){
					res.data.content = res.data.content.replace(/\<img/gi, '<img style="max-width:100%;height:auto;" ')
					this.detail = res.data;
				}
			}
		}
	}
</script>

<style scoped lang="less" src="./notice-detail.less">
</style>
